import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/*
    反射Method
 */
public class ReflectTest05 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class userServiceClass = Class.forName("UserService");

        Method[] methods = userServiceClass.getDeclaredMethods();

        //遍历Method
        for (Method method: methods) {
            //获取修饰符列表
            System.out.print(Modifier.toString(method.getModifiers()) + " ");
            //获取方法的返回值类型
            System.out.print(method.getReturnType().getSimpleName() + " ");
            //获取方法名
            System.out.print(method.getName() + " ");
            //方法的修饰符列表（可能会有多个修饰符列表）
            Class[] parameterTypes = method.getParameterTypes();
            for (Class parameterType: parameterTypes) {
                System.out.print(parameterType.getSimpleName() + " ");
            }
            System.out.println();
        }
    }
}


//用户业务类
class UserService{
    public boolean login(String name, String password){
        if("admin".equals(name)  && "123".equals(password)){
            return true;
        }
        return false;
    }

    public void logout(){
        System.out.println("系统安全退出");
    }
}